package game.module.kefu.logic;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import game.entity.PlayingRole;
import game.module.kefu.bean.QuestionFeedback;

public class QuestionFeedbackManager {

	private static Logger logger = LoggerFactory.getLogger(QuestionFeedbackManager.class);

	static class SingletonHolder {
		static QuestionFeedbackManager instance = new QuestionFeedbackManager();
	}

	public static QuestionFeedbackManager getInstance() {
		return SingletonHolder.instance;
	}

	public void addQuestionFeedback(PlayingRole playingRole, String question,String questionContent) {
		QuestionFeedback qfb = new QuestionFeedback();
		qfb.setPlayerId(playingRole.getId());
		qfb.setQuestion(question);
		qfb.setQuestionContent(questionContent);
		logger.info("----添加客服反馈：question = {} ，questionContent = {}",question,questionContent);
		QuestionFeedbackDaoHelper.getInstance().asyncInsertQuestionFeedback(qfb);
	}

	public void updateQuestionFeedback(int id, String answer){
		logger.info("----更新客服反馈：id = {} ，answer = {}",id,answer);
		QuestionFeedbackDaoHelper.getInstance().asyncUpdateQuestionFeedback(id, answer);
	}
	
	
	public List<QuestionFeedback>  selectLimtQuestionFeedback(boolean isAnswer) {
		logger.info("----批量查询所有客服反馈----isAnswer = {}",isAnswer);
		return QuestionFeedbackDaoHelper.getInstance().selectLimtQuestionFeedback(isAnswer);
	}
	
	public QuestionFeedback  selectQuestionFeedbackById(int id) {
		logger.info("----根据id查询客服反馈----id = {}",id);
		List<QuestionFeedback> list = QuestionFeedbackDaoHelper.getInstance().selectByid(id);
		if (!list.isEmpty()) {
			return list.get(0);
		}
		return null;
	}
	
	
}
